<template>
  <div class="app-container">
        <div>
               <el-button type="primary" @click="workTime">客服工作时间为8:30--17:30</el-button>
               <el-button type="primary" @click="Hangautomati"> 30分钟自动挂断  {{valueTime}} </el-button>
        </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
          // timeOut : 30 * 60 * 1000,//30分钟
           timeOut : 3 * 1000,//3s
           timerTime:"",
           valueTime:0,

    };
  },
  mounted(){

  },
  methods: {
     Hangautomati(){
            //时间到了做一些操作
            this.timerTime = setTimeout(() => {
               this.valueTime=100
            }, 2000);
     },
      workTime(){
          let timeTime= this.timeLimeFm("9:00", "23:00")
          console.log( timeTime )
      },
      //客服工作时间为8:30--17:30
      timeLimeFm(beginTime, endTime){
          console.log('111122222')
          var strb = beginTime.split(":");
          if (strb.length != 2) {
            return false;
          }
          var stre = endTime.split(":");
          if (stre.length != 2) {
            return false;
          }
          var b = new Date();
          var e = new Date();
          var n = new Date();
          b.setHours(strb[0]);
          b.setMinutes(strb[1]);
          e.setHours(stre[0]);
          e.setMinutes(stre[1]);
          if (n.getTime() - b.getTime() > 0 && n.getTime() - e.getTime() < 0) {
            console.log(true)
            return true;
          } else {
            console.log(false)
            return false;
          }  
      }

    
  }
};
</script>